<!-- BaseForm.vue -->
<template>
  <div>
    <el-form :model="form">
      <el-form-item label="商品名称">
        <el-input v-model="form.name" maxlength="45" />
      </el-form-item>

      <el-form-item label="商品类目">
        <el-input v-model="form.category" placeholder="请输入类目关键词" />
      </el-form-item>

      <el-form-item label="商品图片">
        <el-upload
          action="/upload"
          list-type="picture-card"
          :on-preview="handlePictureCardPreview"
          :on-remove="handleRemove"
        >
          <i class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>

      <el-form-item label="封面视频">
        <el-upload
          action="/upload"
          :limit="1"
          accept="video/*"
          :file-list="videoList"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
        >
          <el-button type="primary">上传视频</el-button>
        </el-upload>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "BaseForm",
  prop: {
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    }
  },
  data() {
    return {
      form: {
        name: "",
        category: "",
      },
      videoList: [],
    };
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      console.log(file);
    },
  },
};
</script>
